<script type="text/javascript" language="javascript">
    <!--
    function onBrowsClick(btnBrowse,imgPhoto)
    {
         //$("#imgPhoto").attr("src","E:\BS\Websites\sfproject\web\images\ad_01.jpg");//$("#btnBrowse").val()
    }
    function onCheckClick(ckContent)
    {
        if(ckContent.checked)
            ckContent.value="true";
        else
            ckContent.value="false"
        if(ckContent.name=="ckFocusContent")
        {
            //var url = "<?php echo url_for("other/focus"); ?>" + "?random=" +  Math.random() + "&catalogId=1000&contentTypeId=1000";
            //var focusId = window.showModalDialog(url,null,"dialogWidth:800px;dialogHeight:400px;help:0;status:0;scroll:1;center:1;resizeable:off;");
            //if(focusId != null)
              //$("#txtHideFocusId").val(focusId);
            if(ckContent.checked)
                $("#divFocus").css("display","block");
            else
                $("#divFocus").css("display","none");
        }
    }

    var relatedNews = "";
    var relatedPhoto = "";
    var relatedVideo = "";
    var currentTab = "news";
    var orderStr = "";
    function onRelatedCheckClick(ckRelated, relatedType)
    {
        if(ckRelated != null)
        {
            var tempValue = ckRelated.name ;//+ "," + ckRelated.value
            switch(relatedType)
            {
                case "news":
                   if(ckRelated.checked)
                        relatedNews += tempValue + ";";
                   else
                        relatedNews = relatedNews.replace(tempValue + ";","");
                   break;
                case "photo":
                   if(ckRelated.checked)
                        relatedPhoto += tempValue + ";";
                   else
                        relatedPhoto = relatedNews.replace(tempValue + ";","");
                   break;
                case "video":
                   if(ckRelated.checked)
                        relatedVideo += tempValue + ";";
                   else
                        relatedVideo = relatedNews.replace(tempValue + ";","");
                   break;
            }
        }
    }

    function onSubmit(submitType)
    {
        $("#txtHideRelatedNews").val(relatedNews.substr(0,relatedNews.length-1));
        $("#txtHideRelatedPhoto").val(relatedPhoto.substr(0,relatedPhoto.length-1));
        $("#txtHideRelatedVideo").val(relatedVideo.substr(0,relatedVideo.length-1));
        switch(submitType)
        {
            case "add":
               $("#txtSubmitType").val("add");
        }
        //return true;
    }

    function onSearch()
    {
        if($.trim($("#txtSearch").val()) == "")
        {
            alert("请输入 Tag 值。");
            return ;
        }
        $("#btnSearch").attr("disabled",true);
        var onSearchingMessage = "正在搜索......";
        switch(currentTab)
        {
            case "news":
                $("#divListNews").html(onSearchingMessage);
                break;
            case "video":
                $("#divListVideo").html(onSearchingMessage);
                break;
            case "photo":
                $("#divListPhoto").html(onSearchingMessage);
                break;
        }
        var random = Math.random();
        var searchArray = $.trim($("#txtSearch").val()).split(/,|，/);
        var whereStr = "";
        for(var i = 0 ; i < searchArray.length; i++)
        {
            if(i == 0)
                whereStr = "tag like '%" + searchArray[i] + "%'";
            else
                whereStr += " or " + "tag like '%" + searchArray[i] + "%'";
        }
        whereStr = encodeURI("(" + whereStr + ")");
        $.ajax({url:"<?php echo url_for("other/jQuery");?>",data:"random=" + random +"&submitFlag=relatedSearch&whereStr=" + whereStr +"&searchType=" + currentTab ,success: onSuccessSearch,error:onErrorSearch})
    }

    function onSuccessSearch(oMessage)
    {
        switch(currentTab)
        {
            case "news":
               //alert(oMessage);
               $("#divListNews").html(oMessage);
               break;
            case "video":
               $("#divListVideo").html(oMessage);
               break;
            case "photo":
               $("#divListPhoto").html(oMessage);
               break;
        }

        $("#btnSearch").attr("disabled",false);
    }

    function onErrorSearch(x, e)
    {
        alert(x.responseText);
        $("#btnSearch").attr("disabled",false);
    }

    function onTabClick(tabId)
    {
        switch(tabId)
        {
            case "tabNews":
                 //设置tab
                 $("#tabPhoto").removeClass("tabOn");
                 //$("#tabPhoto").addClass("tab");
                 $("#tabVideo").removeClass("tabOn");
                 //$("#tabVideo").addClass("tab");
                 //$("#tabNews").removeClass("tabOn");
                 $("#tabNews").addClass(" tabOn");
                 //$("#divNews").css("display","background-color: #eeeeee");
                 //设置div
                 $("#divPhoto").css("display","none");
                 $("#divVideo").css("display","none");
                 $("#divNews").css("display","block");
                 currentTab = "news";
                 break;
            case "tabPhoto":
                 //设置tab
                 $("#tabNews").removeClass("tabOn");
                 $("#tabVideo").removeClass("tabOn");
                 $("#tabPhoto").addClass("tabOn");

                 //设置div
                 $("#divPhoto").css("display","block");
                 $("#divVideo").css("display","none");
                 $("#divNews").css("display","none");
                 currentTab = "photo";
                 break;
            case "tabVideo":
                 //设置tab
                 $("#tabPhoto").removeClass("tabOn");
                 $("#tabNews").removeClass("tabOn");
                 $("#tabVideo").addClass("tabOn");

                 //设置div
                 $("#divPhoto").css("display","none");
                 $("#divVideo").css("display","block");
                 $("#divNews").css("display","none");
                 currentTab = "video";
                 break;
        }
    }


    function onImageBrowse(fileControlName,imageControlName)
    {
        var finder = new CKFinder();
	    finder.basePath = '/uploads/';	// The path for the installation of CKFinder (default = "/ckfinder/").
	    finder.selectActionFunction = function(fileUrl){$("#"+imageControlName).attr("src",fileUrl);$("#"+fileControlName).val(fileUrl)};
	    finder.popup();
        //var focusId = window.showModalDialog(url,null,"dialogWidth:800px;dialogHeight:400px;help:0;status:0;scroll:1;center:1;resizeable:off;");
    }
    
    function checkLen(a, s){
        var len=s.length;
        $('#'+a).html(', 已输入'+len+'个字');
    }
    //-->
</script>
<div>
	<form id="form1" name="form1" method="post" enctype="multipart/form-data">
		<table width="100%" height="623" border="0" cellpadding="0" cellspacing="0">
		  <tr>
			<td class="newsTd">新闻发布：</td>
			<td align="right" style="padding-right:300px"><input name="btnBack" type="button" value="取 消" onclick="history.go(-1);" /></td>
		  </tr>
		  <tr>
			<td class="newsTd">栏目：</td>
			<td><?php @include_component("other","catalog",array("selectedId"=>$sf_request->getParameter("catalogId"))); ?></td>
		  </tr>
		  <tr>
			<td class="newsTd">子栏目：</td>
		    <td><?php @include_component("other","contentCatalog",array("selectedId"=>$sf_request->getParameter("subCatalogId"))); ?></td>
		  </tr>
		  <tr>
		    <td class="newsTd">文档属性：</td>
			<td>头条
			  <input type="checkbox" name="ckHeaderContent" value="false" onclick="onCheckClick(this)" />&nbsp;&nbsp;&nbsp;
			  推荐
			  <input type="checkbox" name="ckRecommendContent" value="false" onclick="onCheckClick(this)" />&nbsp;&nbsp;&nbsp;
			  焦点
			  <input type="checkbox" name="ckFocusContent" value="false" onclick="onCheckClick(this)" />&nbsp;&nbsp;&nbsp;
              置顶
              <input type="checkbox" name="ckTop" value="false" onclick="onCheckClick(this)" />
            </td>

		  </tr>
          <tr>
              <td colspan="2">
                  <div id="divFocus" style="display:none;"><?php echo @include_component("other","focus"); ?></div>
              </td>
          </tr>
		  <tr>
			<td class="newsTd">标题：
			  </td>
			<td><input class="focusText" type="text" name="txtTitle" onkeyup="checkLen('checkTitle', this.value)" /> 28个字以内<span id="checkTitle"></span>
<!--			  (28字以内）-->
			</td>
		  </tr>
		  <tr>
			<td class="newsTd">短标题：
			  </td>
			<td>
			 <input class="focusText" type="text" name="txtBriefTitle" onkeyup="checkLen('checkBriefTitle', this.value)" /> 10个字以内<span id="checkBriefTitle"></span>
<!--			  （10个字以内）-->
			</td>
		  </tr>
		  <tr>
			<td class="newsTd">短评：
			  </td>
			<td>
			<input class="focusText" type="text" name="txtShortComment"  onkeyup="checkLen('checkShortComment', this.value)" /> 10个字以内<span id="checkShortComment"></span>
<!--			  （10个字以内）-->
			</td>
		  </tr>
		  <tr>
			<td class="newsTd">作者：
			  </td>
			<td><input type="text" name="txtAuthor" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			  来源：
			  <input type="text" name="txtSource" />
			</td>
		  </tr>
		  <tr>
			<td colspan="2"><table width="90%" border="0" cellspacing="0" cellpadding="0">
			  <tr>
				<td width="62px" height="25px">TAG标签：</td>
                <td><input class="focusText" type="text" name="txtTag" onkeyup='$("#txtSearch").val(this.value);'/></td>
				<td width="60%" rowspan="2">多个关键字和TAG标签，请以“，”分隔</td>
			  </tr>
			  <tr>
				<td width="62px" height="25px" align="right">关键字：</td>
                <td><input class="focusText" type="text" name="txtKeyword" /></td>
			  </tr>
			</table></td>
		  </tr>
          <tr>
              <td class="newsTd">缩略图：</td>
              <td>
                  <table width="90%" height="53" border="0" cellpadding="0" cellspacing="0">
			  <tr>
				<td width="40%"><input class="focusText" name="txtSnapshot" type="text" id="txtSnapshot" />&nbsp;<input type="button" onclick="getFileUrlFromCKFinder('txtSnapshot','imgSnapshot')" value="浏览图片"> </td>
				<td><img name="imgSnapshot" width="256px" height="192px" id="imgSnapshot" src="/images/news_blank.jpg" /></td>
			  </tr>
			</table>
              </td>
          </tr>
		  <tr>
			<td class="newsTd" align="right">内容：</td>
            <td></td>
		  </tr>
		  <tr>
			<td colspan="2"><textarea id="txtBody" name="txtBody"></textarea></td>
		  </tr>
		  <tr>
			<td class="newsTd">是否审核：</td>
            <td>
                <input type="radio" name="check" value="true" disabled="true" />是&nbsp;&nbsp;&nbsp;
                <input type="radio" name="check" value="false"  checked="checked" disabled="true"/>否&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                发布时间：<input type="text" name="txtPublishTime" id="txtPublishTime" value="<?php echo $publishTime ;?>" />&nbsp;&nbsp;<input type="button" value="设为当前时间" onclick="$('#txtPublishTime').val(getCurrentDateTimeStr());"/></td>
		  </tr>
		  <tr>
			<td class="newsTd">内容简介：</td>
            <td></td>
		  </tr>
          <tr>
              <td colspan="2">
                  <textarea name="txtBrief" id="txtBrief" rows="3" cols="105" style=""></textarea>
              </td>
          </tr>
          <tr>
              <td align="right" valign="bottom" style="height:40px;">相关搜索：</td>
              <td valign="bottom"><input type="text" name="txtSearch" id="txtSearch">&nbsp;&nbsp;<input type="button" id="btnSearch" value="搜 索" onclick="onSearch()">&nbsp;(请输入 Tag 值，多个Tag值，请以逗号“，”分隔)</td>
          </tr>
		  <tr>
			<td colspan="2">
                <table height="100%" width="100%" cellSpacing="0" cellPadding="0" style="width:930px;">
			<tr height="25px">
				<td style="padding-left:10px">
					<table style="height: 22px;" cellSpacing="0" cellPadding="0" border="0">
						<tr valign="bottom">
							<td vAlign="bottom" style="FONT-SIZE: 9pt"><span class="tab tabOn" tabIndex="0" id="tabNews" tabID="tab0" onclick="onTabClick('tabNews')">相关新闻</span><span class="tab" tabIndex="1" tabID="tab2" id="tabVideo" onclick="onTabClick('tabVideo')">相关视频</span><span class="tab" tabIndex="2" tabID="tab2" id="tabPhoto" onclick="onTabClick('tabPhoto')">相关图片</span></td>
						</tr>
					</table>
				</td>
			</tr>
            <tr>
				<td style="padding-left:5px">
                    <div class="tab" id="divNews">
                        <div class="lists" id="divListNews">在“相关搜索”文本框中，输入相应的 Tag 值，点击“搜索”按钮，即可找到相关的 新闻 信息。</div>
                    </div>
                    <div class="tab" id="divVideo" style="display:none;">
                        <div class="lists" id="divListVideo">在“相关搜索”文本框中，输入相应的 Tag 值，点击“搜索”按钮，即可找到相关的 视频 信息。</div>
                    </div>
                    <div class="tab" id="divPhoto" style="display:none;">
                        <div class="lists" id="divListPhoto">在“相关搜索”文本框中，输入相应的 Tag 值，点击“搜索”按钮，即可找到相关的 图片 信息。</div>
                    </div>
                </td>
            </tr>
</table>
			</td>
		  </tr>
		  <tr>
			<td align="center" colspan="2" style="height:50px;"><input name="btnAdd" type="submit" id="btnAdd" value="添 加" onclick="onSubmit('add')" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="btnBack" type="button" value="取 消" onclick="history.go(-1);" /><input name="btnPublish" type="submit" id="btnPublish" value="发 布" onclick="onSubmit('publish')" style="display:none;" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
		  </tr>
	  </table>
        <input name="txtHideFocusId" type="hidden" id="txtHideFocusId" />
        <input name="txtHideSnapshot" type="hidden" id="txtHideSnapshot" />
        <input name="txtHideRelatedNews" type="hidden" id="txtHideRelatedNews" />
        <input name="txtHideRelatedPhoto" type="hidden" id="txtHideRelatedPhoto" />
        <input name="txtHideRelatedVideo" type="hidden" id="txtHideRelatedVideo" />
        <input name="txtSubmitType" value="add" type="hidden" id="txtSubmitType" />
        <?php
	// Include CKEditor class.
	//include_once "../../ckeditor.php";
	// Create class instance.
	$CKEditor = new CKEditor();
	// Path to CKEditor directory, ideally instead of relative dir, use an absolute path:
	//   $CKEditor->basePath = '/ckeditor/'
	// If not set, CKEditor will try to detect the correct path.
	//$CKEditor->basePath = '../../';
    $CKEditor->basePath = '/ckeditor/';
    //$CKEditor->
	// Replace textarea with id (or name) "editor1".
	$CKEditor->replace("txtBody");
	?>
	</form>
</div>
